<?php

namespace app\payment;

class PayFactory
{
    const WECHAT = 'wechat';

    const ALIPAY = 'ali';

    const PAYPAL = 'paypal';

    const BALANCE = 'balance';
    const INTEGRAL = 'integral';

    const CONTRIBUTION = 'contribution';

    const COMMISSION = 'commission';
    const FREEZE_COMMISSION = 'freeze_commission';


    const RECHARGE_BALANCE = 'recharge_balance';

    public static function create($payWay): AbstractPay
    {
        $className = ucfirst(strtolower($payWay)) . 'Pay';

        $fullClassName = __NAMESPACE__ . "\\" . $className;

        if (class_exists($fullClassName)) {
            return new $fullClassName;
        }

        throw new \Exception('不支持的支付方式');
    }
}